package de.hska.kundenverwaltung.db;

import static de.hska.kundenverwaltung.db.Kunde.FIRMENKUNDE;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Inheritance;

@Entity
@Inheritance
@DiscriminatorValue(FIRMENKUNDE)
public class Firmenkunde extends Kunde {
	private static final long serialVersionUID = -3962271877965533586L;

	@Column
	private float rabatt;

	public Firmenkunde() {
		super();
	}
	public Firmenkunde(String nachname, String vorname, String email, Date seit, float rabatt) {
		super(nachname, vorname, email, seit);
		this.rabatt = rabatt;
	}

	public float getRabatt() {
		return rabatt;
	}
	public void setRabatt(float rabatt) {
		this.rabatt = rabatt;
	}

	@Override
	public String getArt() {
		return FIRMENKUNDE;
	}
	
	@Override
	public int hashCode() {
		final int PRIME = 31;
		int result = super.hashCode();
		result = PRIME * result + getArt().hashCode();
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "{" + super.toString() + ", rabatt=" + rabatt + '}';
	}
}
